
function randCode(count) {
    var count = count || 4;

    if(!(count>0 && count % 1 == 0)) {  // 如果不是 >0 的整数 就抛错
        var err = new Error("Please pass in a positive integer greater than 0!");    // new Error(errMessage)  创建错误
        throw err;  // 抛出错误
    }

    // var list = ["a","b","c","d","e","f","g","h"];
    var list = "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM".split("");
    
    var codeStr = "";  // 验证码
    for (var i = 0; i < count; i++) {   // 假设i=1时 随机的字符重复
        var index = Math.floor(Math.random() * list.length);
        var char = list[index];
        if (!codeStr.includes(char)) {  // 验证码中不存在的字符
            codeStr += char;
        } else {  // 已存在  => 不做任何操作的话就会少一个字符
            console.log(char + "已存在");
            count++;  // 本次也算  但是再送你一次
        }
    }
    console.log(codeStr);
    return codeStr;
}